<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        table {
            margin: 50px auto;

        }

        table,
        tr,
        th,
        td {
            border: 1px solid #000;



        }

        th,
        td {
            padding: 3px 60px;
        }

        .body {
            margin: auto;
            width: 500px;
            height: 200px;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
        }

        .title {
            text-align: center;
        }

        .input {
            margin-left: 82px;
        }

        .body div span {
            display: inline-block;
            width: 80px;
            text-align: right;
        }

        td {
            text-align: center;
        }

        #add {
            margin-left: 200px;
            margin-right: 10px;
        }
    </style>
    <script>
        function doAdd() {
            //获取文本框的值
            var name = document.getElementById("name").value;
            var age = document.getElementById("age").value;
            var email = document.getElementById("email").value;
            var male = document.getElementById("male");//获取男的DOM对象
            var female = document.getElementById("female");//获取女的DOM对象
            /* 
            if(male.checked){//如果男的被选中
                var sex=male.value;
            }else{
                var sex=female.value;
            } */
            var sex = male.checked ? male.value : female.value;
            var arrs=[name,age,sex,email,"<input type='button' value='删除' onclick='doRemove(this)'>"];
            var tr=document.createElement("tr");//创建tr元素
            for(var i=0;i<5;i++){//循环创建4列
                var td=document.createElement("td");//创建td元素
                td.innerHTML=arrs[i];//向td中添加文本内容
                tr.appendChild(td);//将td添加到tr中去
            }
            var tb=document.querySelector("tbody");
            tb.appendChild(tr);

        }

        function doRemove(obj){
            obj.parentNode.parentNode.remove();
        }
    </script>
</head>

<body>
    <table>
        <tbody>
            <tr>
                <th>Name</th>
                <th>Age</th>
                <th>Gender</th>
                <th>Email</th>
                <th>操作</th>
            </tr>
            <tr>
                <td>mike</td>
                <td>20</td>
                <td>男</td>
                <td>222@qq.com</td>
                <td><input type="button" value="删除" onclick="doRemove(this)"></td>
            </tr>
            <tr>
                <td>mike2</td>
                <td>20</td>
                <td>男</td>
                <td>222@qq.com</td>
                <td><input type="button" value="删除" onclick="doRemove(this)"></td>
            </tr>
        </tbody>
    </table>
    <form action="">
        <div class="body">
            <div class="title">Pls Input Info</div>
            <div class="input"><span>Name：</span><input type="text" value="" id="name"></div>
            <div class="input"><span>Age：</span><input type="text" value="" id="age"></div>
            <div class="input"><span>Gender：</span>
                <input type="radio" name="sex" value="男" id="male" checked><label for="male">男</label>
                <input type="radio" name="sex" value="女" id="female"><label for="female">女</label>
            </div>
            <div class="input"><span>Email：</span><input type="text" value="" id="email"></div>
            <div>
                <input type="button" value="添加" id="add" onclick="doAdd()">
                <input type="reset" value="重置" id="reset">
            </div>
        </div>
    </form>
    <script>

    </script>
</body>

</html>